package com.aos.erp.schools.rest.common;

import com.aos.erp.common.bean.ResultEntity;
import com.aos.erp.schools.model.common.Dict;
import com.aos.erp.schools.model.common.Region;
import com.aos.erp.schools.service.common.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: erp
 * @description: 数据字典
 * @author: tanzhiyu
 * @create: 2018-11-09 19:26
 **/
@Api(value = "数据字典", tags = {"数据字典API"})
@RestController("RESTDictController")
@RequestMapping("/api/dict")
public class DictController {
    @Resource
    private DictService dictService;

    @ApiOperation(value = "获取数据字典")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "数据code", required = true, dataType = "String", paramType = "Query")
    })
    @PostMapping("/getDict")
    public ResultEntity getDict(String code) throws Exception {
        if (StringUtils.isEmpty(code)){
            return ResultEntity.failed("数据code不能为空", ResultEntity.CODE_NULL);
        }
        List<Dict> list=dictService.findByParams(code);
        return ResultEntity.success(list,"获取数据字典");
    }

}
